home *** CD-ROM | disk | FTP | other *** search
/ Aminet 12 / Aminet 12 (1996)(GTI - Schatztruhe)[!][Jun 1996].iso / Aminet / dev / lang / HeliOS3.lha / helios_demo_disk3 / source / TextandFractalDemo.src < prev    next >
Encoding:
Text File  |  1995-02-24  |  67.1 KB  |  2,658 lines

  1.  
  2.  
  3.  ( This software is freely provided for your entertainment and help.
  4.  
  5.    Please use it for any purposes which you wish, and incorporate any parts
  6.    which you find useful into your own programs.
  7.  
  8.    Instead of the usual simple "single function" example, we have here
  9.    given you a fairly long program which, although it is primitive, does
  10.    at least give you working examples of many commonly used functions.
  11.  
  12.    This source code shows methods of getting user input, outputting text
  13.    and simple graphics, and generally getting your feet wet in the muddy
  14.    waters of some fairly messy code!  And, yes....some of this code shows
  15.    you how not to do things too.....
  16.  
  17.    The demo uses admittedly simple and crude programming techniques to
  18.    demonstrate simple text output.  In fact it does nothing much else but
  19.    present a lot of simple text screens with a few fractal demos thrown
  20.    in to alleviate the boredom!
  21.  
  22.    It would have been much better to use nicely drawn line and bevel boxes
  23.    to make the displays more professional and attractive looking, and this
  24.    actually would not be hard to do.  However, we wanted to keep things
  25.    really simple and emphasise the basic text commands rather than make
  26.    the code more complex.
  27.  
  28.    In fact you will find that all the demo code is quite simple except for
  29.    some of the fractal routines.
  30.  
  31.    The fractal code is not sophisticated but may prove incomprehensible
  32.    if you haven't seen this type of thing before.  We recommand that you
  33.    don't waste time trying to follow this code unless you are really a
  34.    great fractal enthusiast.
  35.  
  36.    Really the fractals are an excuse to use a variety of text displays,
  37.    and we don't recommend that you try to re-use the fractal code itself,
  38.    which is not intended as tutorial material.
  39.  
  40.    The real point of this demo is to show how you can get a useable piece
  41.    of software of reasonable length running without complication, and show
  42.    how to output simple text and get user keyboard input.
  43.  
  44.    Every routine has been kept at a fairly elementary and obvious level,
  45.    sacrificing elegance, cleverness, or speed in an effort to make the code
  46.    fairly comprehensible and clear.  You might like to try, as an exercise,
  47.    improving some of this code and writing your own faster and more elegant
  48.    version.  Certainly you should not assume that the way things are done
  49.    here is the only or best way.
  50.  
  51.    Various different methods are employed to do the same job in different
  52.    parts of the code, simply to give you an idea of the options available.
  53.    For example, cursor positioning and text formatting can be carried out
  54.    in many different ways, and in many cases it doesn't really matter how
  55.    you choose to do it.
  56.  
  57.    Note that all text has been stored in the dictionary, which is lazy and
  58.    wasteful of dictionary space, but nice and simple!  A more serious text
  59.    generating program would store the text in external memory, leaving the
  60.    dictionary uncluttered.
  61.  
  62.    The first section demonstrates how easy it is to format text output
  63.    using the HeliOS stream system, and lots of different streams are used
  64.    throughout to give you some experience of using them.
  65.  
  66.    Actually, you could write this simple program using only one stream.....
  67.  
  68.    If you don't know where to start looking through a long-ish program
  69.    like this, then go first to the end of the file, where you will find
  70.    the main program control words.
  71.  
  72.    In general, in HeliOS, you write all the sub-routines and subsidiary
  73.    words first, then call them later in the more "high-level" routines.
  74.    This means that HeliOS programs tend to start with a number of small
  75.    "utility" word definitions, which in turn are used to build all the main
  76.    working components of the program.  Finally the whole thing is brought
  77.    together at the very end of the code by words which define the highest
  78.    level of the overall program structure.  In other words, HeliOS programs
  79.    exhibit a sort of pyramidal or hierarchical structure, with the "command
  80.    and control centre" at the end of the source code.
  81.  
  82.    This means that if you want an overview of any HeliOS program you should
  83.    go to the end first.  If you want to inspect the small "nuts and bolts"
  84.    routines you should look, in general, at the start of the program.
  85.  
  86.    Note that the final thing in most HeliOS programs is a single word which
  87.    invokes the main program definition word.  In the present case the last
  88.    thing in the program is the word "Demo", which runs the demo main control
  89.    routine.
  90.  
  91.    The placement of the main command word "Demo" at the end of the program
  92.    means that once you have compiled this code it will run automatically.
  93.  
  94.    Subsequently, if you wish, you can re-run the program by typing its main
  95.    control word "Demo" at the command line (or in a program of course).
  96.  
  97.    You could omit the final word "Demo" in this program, and if you did so
  98.    you would find that the program would compile without auto-running.  You
  99.    would then need to type the word "Demo" at the command line to run the
  100.    program.
  101.  
  102.    Considering source code format and style, note that plenty of blank
  103.    lines can be employed to space out your code and make it less cluttered.
  104.    Because all trailing spaces are suppressed when lines of text are stored,
  105.    each blank line only takes up one byte of memory and file space.
  106.  
  107.    Some of the code in this demo is very untidy, and you will notice that
  108.    the badly laid out code is unreadable and therefore harder to debug and
  109.    maintain.  You will see that short, self contained, sections of code are
  110.    easiest to read and become almost self explanatory, because you can take
  111.    in the whole of the logical structure on one page.
  112.  
  113.    Sometimes it is reasonable to create long word definitions for simple
  114.    sequential operations which contain no program flow control logic, since
  115.    these are fairly clear to read anyway.  In general, though, you should
  116.    always confine tricky bits of logic, or any code defining individual
  117.    functional units, to short self-contained word definitions.
  118.  
  119.    If you do this you will find that it is easy to change these "units"
  120.    without in any way compromising the main program logic.  Notice also
  121.    that all small functional "units" of code should have "stack diagrams"
  122.    telling you exactly how they interact with the main program when they
  123.    are "called".  In a language such as HeliOS which uses the stack for
  124.    parameter passing it is important to always make absolutely clear just
  125.    what is happening to the stack when each word executes.
  126.  
  127.    Look at the word "TEXTDEMO" for an example of horrible code, and look
  128.    at "DEMOCOLOURS" for an example of fairly neat and readable code.  Make
  129.    your own judgments as to which is best.........
  130.  
  131.    Notice that throughout this program we have used upper case characters
  132.    for word names.  This is not essential, and in fact you can define a
  133.    word in one case (or mixed case) and then call it with characters in
  134.    either upper or lower case.
  135.  
  136.    In this program we used upper case for commands so that your eye could
  137.    easily pick out the command words from all the text and commentary.
  138.    This can sometimes be useful, but on other occasions it might be useful
  139.    to have CORE words in upper case and ones you have defined yourself in
  140.    mixed case.  Really this is simply a matter of what you think looks best
  141.    and is easiest to read, so try out various combinations until you feel
  142.    comfortable that your code is easy to read.
  143.  
  144.    Note that we have sometimes used "indenting" to make structured sections
  145.    of code such as DO-LOOP and BEGIN-UNTIL constructs more readable.  In
  146.    general this is a very good idea, and if you compare the word "RAYS"
  147.    with the word "TURNWINDOW" you will perhaps see what we mean.
  148.  
  149.    Finally, you might be interested that the Mandelbrot generator uses a
  150.    tiny fragment of assembler code, just to give you a taste of how this
  151.    is done in HeliOS.
  152.  
  153.    *******
  154.    WARNING
  155.    *******
  156.  
  157.    This code makes extensive use of comments, which is always a good idea.
  158.  
  159.    However you MUST BE CAREFUL of one or two things which sometimes cause
  160.    problems with HeliOS comments:
  161.  
  162.    1.  You MUST include spaces before AND after "(" (comment start) symbols.
  163.  
  164.    2.  You MUST include spaces before AND after ")" (comment end) symbols.
  165.  
  166.    3.  You MUST include spaces before AND after "\" (line comment) symbols.
  167.  
  168.    4.  Be careful not to mis-type a "/" (divide) character instead of a "\".
  169.  
  170.    5.  You can use "(" and ")" brackets within comments delimited by these
  171.        same characters, but if you do so you must NOT use spaces around the
  172.        brackets WITHIN the comment.
  173.  
  174.    6. If you get strange compile errors with "Word not found" etc., always
  175.       check for mistakes in your comment markers.
  176.  
  177.    Look at the way this comment is written as an example. )
  178.  
  179.  \ ---------------------------------------------------------------------------
  180.  
  181.    ( First clear dictionary down to core vocabulary )
  182.  
  183.    FORGET **CORE**
  184.  
  185.  \ ---------------------------------------------------------------------------
  186.  
  187.    ( Load and compile ASSEMBLER vocabulary for later use )
  188.  
  189.    RUN Helios:Assembler
  190.  
  191.  \ ----------------------------------------------------------------------------
  192.  
  193.    ( Next make new definitions of some non-time-critical words which
  194.      are used frequently in the Demo.
  195.  
  196.      This is not really necessary in this particular case, but is
  197.      included simply to demonstrate the technique.
  198.  
  199.      Here we are making simple "compound" words to use instead of
  200.      continually making multiple repeated use of the one word "CR".
  201.  
  202.      In this way we:
  203.  
  204.       1. Save compile time  as the compiler will not have to search
  205.          deep in the dictionary for the word "CR" all the time.
  206.  
  207.       2. Make our source code shorter and less cluttered with "CR"s.
  208.  
  209.      There is a small execution time penalty, but this is unimportant. )
  210.  
  211.    : 1CR  CR ;                    \ Redefine Carriage Return
  212.  
  213.    : 2CR  1CR 1CR ;               \ 2 CRs
  214.  
  215.    : 3CR  2CR 1CR  ;              \ 3 CRs
  216.  
  217.    : 4CR  2CR 2CR ;               \ 4 CRs
  218.  
  219.  \ ----------------------------------------------------------------------------
  220.  
  221.    ( A word to clear the two pixel lines above the start of the text area
  222.      in the HeliOS main display.  This does not get cleared by the console
  223.      text window SCRCLR routine because the console window starts two pixels
  224.      below the start of the window. )
  225.  
  226.    : CLEARWINDOWTOP    ( Colour - - - )
  227.  
  228.    GFXSETAPEN                       \ Set drawing pen from stack value
  229.    0 0  GFXORIGIN                   \ Set drawing origin to top left corner
  230.    4 13 GFXMOVE 635 13 GFXDRAW      \ Draw horizontal line at pixel 13
  231.    4 14 GFXMOVE 635 14 GFXDRAW      \ Draw horizontal line at pixel 14
  232.    ;
  233.  
  234.  \ ---------------------------------------------------------------------------
  235.  
  236.    ( A word to clear up and quit the demo )
  237.  
  238.    : DEMOQUIT     ( - - - )
  239.  
  240.    RESETCOLOURS                          \ Restore HeliOS colour defaults
  241.  
  242.    SP!                                   \ Clear Stack
  243.  
  244.    INITFSTREAMS FSTATUS                  \ Remake HeliOS display
  245.  
  246.    2 STREAM                              \ Enter main display area stream
  247.  
  248.    6 6 CURPUT
  249.  
  250.    ." This is the end....hope you've had fun...."
  251.  
  252.    6 8 CURPUT 6 FPENSET
  253.  
  254.    ." Press any key to finally exit."
  255.  
  256.    KEY DROP                              \ Wait for response
  257.  
  258.    SCRCLR                                \ Clear display
  259.  
  260.    QUIT                                  \ Quit
  261.    ;
  262.  
  263.  \ ----------------------------------------------------------------------------
  264.  
  265.    ( A simple word which we shall use to permit the user to control
  266.      progress through the demo )
  267.  
  268.    : WAIT              ( - - - )
  269.  
  270.    6 FPENSET
  271.  
  272.    ."  Press <SPACE> or L-Mouse to continue..."
  273.  
  274.    BEGIN                                \ Wait for any previous key
  275.      ?TERMINAL 0=                       \ press to be released
  276.    UNTIL
  277.  
  278.    WAITSPACE                            \ Wait for <SPACE> to be pressed
  279.    ;
  280.  
  281.  \ ----------------------------------------------------------------------------
  282.  
  283.    ( A bit of demonstration text )
  284.  
  285.    : DEMOTEXT          ( - - - )
  286.  
  287.    ." This is a HeliOS demonstration........"
  288.    ;
  289.  
  290.  \ ----------------------------------------------------------------------------
  291.  
  292.    ( A bit of demonstration text repeated 60 times with 1/50 second delay )
  293.  
  294.    : DEMOTEXT1         ( - - - )
  295.  
  296.    60 0
  297.    DO
  298.      DEMOTEXT
  299.      1 DELAY
  300.    LOOP
  301.    ;
  302.  
  303.  \ ----------------------------------------------------------------------------
  304.  
  305.    ( A bit of demonstration text output 50 times to 3 different streams )
  306.  
  307.    : DEMOTEXT2         ( - - - )
  308.  
  309.    50 0
  310.    DO
  311.      6 STREAM   DEMOTEXT
  312.      7 STREAM   DEMOTEXT
  313.      8 STREAM   DEMOTEXT
  314.    LOOP ;
  315.  
  316.  \ ----------------------------------------------------------------------------
  317.  
  318.  ( A simple graphical display of a pulsating HeliOS sun logo, with
  319.    a subsidiary word RAYS first which generates the radiating pattern
  320.  
  321.    Note that you could replace the repeating code
  322.  
  323.    DDUP  2/ SWAP 2/ SWAP      GFXMOVE  GFXDRAW
  324.  
  325.    with a single word defined to take its place.
  326.  
  327.    Normally you would probably do this to make your code more compact
  328.    and readable. )
  329.  
  330.  
  331.    : RAYS              ( colour1 colour2 - - - colour1 colour2 )
  332.  
  333.    45 0 DO
  334.  
  335.    OVER   GFXSETAPEN                                 \ Set Colour1
  336.  
  337.    150 I 3 LSL     GFXSIN 32767 */  DUP  NEGATE      \ X-Coords
  338.    75  I 3 LSL     GFXCOS 32767 */  TUCK NEGATE      \ Y-Coords
  339.  
  340.    DDUP  2/ SWAP 2/ SWAP      GFXMOVE  GFXDRAW       \ Draw negative ray
  341.    DDUP  2/ SWAP 2/ SWAP      GFXMOVE  GFXDRAW       \ Draw positive ray
  342.  
  343.    DUP   GFXSETAPEN                                  \ set Colour2
  344.  
  345.    180 I 3 LSL 2+  GFXSIN 32767 */  DUP  NEGATE      \ Draw longer rays
  346.    90  I 3 LSL 2+  GFXCOS 32767 */  TUCK NEGATE
  347.  
  348.    DDUP  2/ SWAP 2/ SWAP      GFXMOVE  GFXDRAW
  349.    DDUP  2/ SWAP 2/ SWAP      GFXMOVE  GFXDRAW
  350.  
  351.    LOOP  ;
  352.  
  353.  
  354.    : HELIOS            ( - - - )
  355.  
  356.    BEGIN                                          \ Wait for any previous key
  357.      ?TERMINAL 0=                                 \ press to be released
  358.    UNTIL
  359.  
  360.    STREAMNO                                       \ Get current Stream
  361.  
  362.    0 DUP INITSTREAM STREAM                        \ Init/Enter 0 Stream
  363.  
  364.    2 BPENSET                                      \ Set Colour 2 background
  365.  
  366.    CUROFF 0 STREAM SCRCLR                         \ Set up display
  367.  
  368.    2 CLEARWINDOWTOP                               \ Clear top of window
  369.  
  370.    7 GFXSETAPEN                                   \ Set Colour 7
  371.  
  372.    316 120 DDUP GFXORIGIN                         \ Set GFX Origin
  373.  
  374.    68 34  GFXAREAELLIPSE    GFXAREAEND            \ Draw Disk
  375.  
  376.    37 13 CURPUT 6 FPENSET 7 BPENSET   ." HeliOS"  \ Write Text
  377.    38 14 CURPUT 6 FPENSET 7 BPENSET   ." text"
  378.    38 15 CURPUT 6 FPENSET 7 BPENSET   ." demo!"
  379.  
  380.    3  26 CURPUT 1 FPENSET 2 BPENSET ." Press <SPACE> to continue..."
  381.  
  382.    53 26 CURPUT ." Press <Q> to quit Demo."
  383.  
  384.    6 7                                            \ Colours for RAYS
  385.  
  386.    BEGIN                                          \ Start loop
  387.  
  388.      RAYS                                         \ Display Rays
  389.  
  390.      SWAP                                         \ Alternate colours
  391.  
  392.      ?TERMINAL DUP KEYLCASE ASCII q =
  393.      IF
  394.        DEMOQUIT
  395.      THEN                                         \ ? QUIT
  396.  
  397.      32 =
  398.    UNTIL                                          \ Loop until <Space>
  399.  
  400.    25 DELAY                                       \ 1/2 second delay
  401.  
  402.    DDROP                                          \ Drop colours
  403.  
  404.    0 INITSTREAM                                   \ Reset 0 stream
  405.  
  406.    STREAM  ;                                      \ Restore start stream
  407.  
  408.  \ ----------------------------------------------------------------------------
  409.  
  410.    ( Start of demo ...... Clear screen and output initial message )
  411.  
  412.    : INTRO
  413.  
  414.    0 DUP INITSTREAM STREAM CUROFF   \ Enter and initialise 0 Stream
  415.  
  416.    2 BPENSET                        \ Text background 2 for screen clearing
  417.  
  418.    SCRCLR                           \ Clear screen
  419.  
  420.    4 3 CURPUT                       \ Set cursor etc etc
  421.  
  422.    ." HeliOS has been exclusively developed on the Amiga with the intention "
  423.  
  424.    4 4 CURPUT
  425.  
  426.    ." of providing a high performance programming language which is both"
  427.  
  428.    4 5 CURPUT
  429.  
  430.    ." easy to learn and comprehensive in scope."
  431.  
  432.    4 7 CURPUT
  433.  
  434.    ." HeliOS is a very fast and efficient programming language, explicitly"
  435.  
  436.    4 8 CURPUT
  437.  
  438.    ." designed for the Amiga, with an integrated graphical user interface."
  439.  
  440.    4 10 CURPUT
  441.  
  442.    ." All critical parts of HeliOS are written in machine code for maximum"
  443.  
  444.    4 11 CURPUT
  445.  
  446.    ." speed and power, giving performance equal to any Amiga application."
  447.  
  448.    4 13 CURPUT
  449.  
  450.    ." HeliOS has a unique Interactive mode which allows ideal freedom to"
  451.  
  452.    4 14 CURPUT
  453.  
  454.    ." creative programmers who enjoy experimentation at the keyboard."
  455.  
  456.    4 16 CURPUT
  457.  
  458.    ." HeliOS has an excellent user interface with integrated editor, debugger,"
  459.  
  460.    4 17 CURPUT
  461.  
  462.    ." compiler, and interactive interpreter for ultra rapid program development."
  463.  
  464.    4 19  CURPUT
  465.  
  466.    ." HeliOS is more powerful, and easier to use, than C, Basic, or assembler."
  467.  
  468.    4 21  CURPUT
  469.  
  470.    ." This program will show you a few simple HeliOS text handling and graphic"
  471.  
  472.    4 22  CURPUT
  473.  
  474.    ." drawing functions, and provides an easy-to-follow source code example."
  475.  
  476.    4 24  CURPUT
  477.  
  478.    ." You can freely modify the source code to create your own simple Demo."
  479.  
  480.    3 27  CURPUT
  481.  
  482.    WAIT
  483.    ;
  484.  
  485.  \ ----------------------------------------------------------------------------
  486.  
  487.  ( A small colour selection word, DEMOCOLOURS, with a few subsidiary words.
  488.  
  489.    Notice how this code is broken down into simple functional sub-units. )
  490.  
  491.    0   VARIABLE   RED
  492.    0   VARIABLE   BLUE
  493.    0   VARIABLE   GREEN
  494.    0   VARIABLE   PEN
  495.    0   VARIABLE   NUMCOLS
  496.  
  497.    FIND  NOOP   VARIABLE   EXTERNAL
  498.  
  499.    : SETCOLS      ( - - - )       \ Set RGB values
  500.  
  501.    PEN @
  502.    RED @
  503.    GREEN @
  504.    BLUE @
  505.  
  506.    GFXSETRGB
  507.    ;
  508.  
  509.    : GETCOLS      ( - - - )       \ Get RGB values
  510.  
  511.    PEN @
  512.    GFXGETRGB
  513.  
  514.    BLUE !
  515.    GREEN !
  516.    RED !
  517.    ;
  518.  
  519.    : SHOWCOLOUR    ( - - - )      \ Display Colour Values
  520.  
  521.    CURREAD                        \ Get cursor position on stack
  522.  
  523.    25 CURFW CURSAVE   PEN   ?     \ Output colour values
  524.    CURSET    1 CURDN  RED   ?
  525.    CURSET    2 CURDN  GREEN ?
  526.    CURSET    3 CURDN  BLUE  ?
  527.  
  528.    CURPOS                         \ Restore stored cursor position
  529.    ;
  530.  
  531.    : USERCOLOUR    ( c - - - c )  \ Translate user input
  532.  
  533.    ASCII c OVER=                  \ Was "c" pressed?
  534.    IF
  535.      PEN NUMCOLS @ CYCLE
  536.      GETCOLS
  537.    ELSE
  538.      ASCII x OVER=                \ Was "x" pressed
  539.      IF
  540.        RESETCOLOURS
  541.        GETCOLS
  542.      ELSE
  543.        ASCII r OVER=              \ Was "r" pressed
  544.        IF
  545.          RED 16 CYCLE
  546.        ELSE
  547.          ASCII g  OVER=           \ Was "g" pressed
  548.          IF
  549.            GREEN 16 CYCLE
  550.          ELSE
  551.            ASCII b  OVER=         \ Was "b" pressed
  552.            IF
  553.              BLUE 16 CYCLE
  554.            THEN
  555.          THEN
  556.        THEN
  557.      THEN
  558.    THEN
  559.    ;
  560.  
  561.    : DEMOCOLOURS       ( Number-of-colours - - - )
  562.  
  563.    NUMCOLS !                        \ Store number of colours
  564.  
  565.    PEN 0!                           \ Set pen to zero
  566.  
  567.    CURSTAT                          \ Check Cursor status and save on stack
  568.  
  569.    CUROFF                           \ Set up and display text
  570.  
  571.    CURSAVE            ."  COLOUR BEING ADJUSTED =    "
  572.    CURSET 1 CURDN     ."  RED   COMPONENT       =    "
  573.    CURSET 2 CURDN     ."  GREEN COMPONENT       =    "
  574.    CURSET 3 CURDN     ."  BLUE  COMPONENT       =    "
  575.    CURSET
  576.  
  577.    GETCOLS                          \ Update colour variables
  578.  
  579.    SHOWCOLOUR                       \ Display values
  580.  
  581.    BEGIN                            \ Begin loop
  582.  
  583.      KEY  KEYLCASE                  \ Get a key and translate case
  584.  
  585.      USERCOLOUR                     \ Check user input
  586.  
  587.      SETCOLS                        \ Set display colours
  588.  
  589.      SHOWCOLOUR                     \ Display new values
  590.  
  591.      EXTERNAL @EXECUTE              \ Execute subsidiary word
  592.  
  593.      32 =
  594.  
  595.    UNTIL                            \ Loop until <Space> pressed
  596.  
  597.    RESETCOLOURS                     \ Restore HeliOS default colours
  598.  
  599.    IF                               \ Check cursor status on stack
  600.      CURON                          \ Restore cursor status
  601.    THEN
  602.    ;
  603.  
  604.  
  605.  \ ----------------------------------------------------------------------------
  606.  
  607.  ( Set up 3 text streams )
  608.  
  609.    : INIT3STREAMS  ( - - - )
  610.  
  611.    1 STREAM     1 1  80 5  SCRWIN     0 BPENSET 3 FPENSET  CUROFF SCRCLR
  612.    2 STREAM     1 6  80 20 SCRWIN     7 BPENSET 1 FPENSET  CUROFF SCRCLR
  613.    3 STREAM     1 26 80 5  SCRWIN     2 BPENSET 6 FPENSET  CUROFF SCRCLR
  614.    ;
  615.  
  616.  \ ----------------------------------------------------------------------------
  617.  
  618.  ( A short text stream demonstration - of how NOT to do it!.
  619.  
  620.    The style of this code is not good, because runs to quite a length
  621.    of in-line code which is relatively unreadable and awkward to maintain.
  622.  
  623.    This code section is around 350 lines long!
  624.  
  625.    Old fashioned programming languages used to do this kind of thing,
  626.    and it certainly works on a purely technical level, but just look
  627.    how awkward it is finding your way around 350 lines of code!
  628.  
  629.    A more modular approach with subdivisions of the code would be more
  630.    readable and easy to modify.  In general it is easiest to maintain
  631.    code in which individual sections are self contained "modules" of
  632.    maybe a couple of screens in size.
  633.  
  634.    For example, all the sections of code between the WAIT words could
  635.    be defined as separate words.
  636.  
  637.    You should NOT normally write long single sections of code like this
  638.    and we have only put this here as a demonstration of how awkward such
  639.    code is to read in terms of program structure.
  640.  
  641.    Don't do it like this yourself! )
  642.  
  643.  
  644.    : TEXTDEMO
  645.  
  646.    0 DUP INITSTREAM STREAM        \ Set full size window in 0 Stream
  647.  
  648.    2 BPENSET                      \ Background pen 2
  649.  
  650.    2 CLEARWINDOWTOP               \ Clear top lines
  651.  
  652.    SCRCLR CUROFF                  \ Clear screen and switch off cursor
  653.  
  654.    18 4 CURPUT                    \ Place cursor
  655.  
  656.    7 FPENSET 6 BPENSET BOLDON     \ Set text colour contrast and style
  657.  
  658.    ."                                         "
  659.                                   \ Blank line = top of colour contrast area
  660.  
  661.    18 5 CURPUT
  662.  
  663.    ."   A Simple HeliOS Text Demonstration    "
  664.                                   \ Colour contrast text
  665.  
  666.    18 6 CURPUT
  667.  
  668.    ."                                         "
  669.                                   \ Blank line = bottom of colour contrast
  670.  
  671.  
  672.    3 FPENSET 2 BPENSET BOLDOFF    \ Reset style and colour to normal
  673.  
  674.    4 10 CURPUT
  675.  
  676.    ."  This demonstration uses very simple text commands at an elementary level."
  677.  
  678.    4 12 CURPUT
  679.  
  680.    ."  Everything here can be done easily, even by inexperienced programmers."
  681.  
  682.    4 16 CURPUT
  683.  
  684.    ."  HeliOS text output routines are comprehensive but very easy to learn."
  685.  
  686.    4 19 CURPUT BOLDON 1 FPENSET
  687.  
  688.    ."  In fact everything you see in this demo is simple to do using HeliOS."
  689.  
  690.    4 23 CURPUT BOLDOFF 3 FPENSET
  691.  
  692.    WAIT
  693.  
  694.    0 BPENSET 3 FPENSET
  695.  
  696.    0 CLEARWINDOWTOP
  697.  
  698.    SCRCLR
  699.  
  700.    5 3 CURPUT
  701.  
  702.    ."  First we can look at some elementary text output formatting."
  703.  
  704.    5 6 CURPUT
  705.  
  706.    ."  HeliOS provides you with ten automatically organised text streams,"
  707.  
  708.    5 8 CURPUT
  709.  
  710.    ."  and many powerful and versatile screen display control commands."
  711.  
  712.    5 11 CURPUT 2 FPENSET 1 BPENSET
  713.  
  714.    ."  Power with simplicity of operation allows you freedom to be creative."
  715.  
  716.    5 14 CURPUT 1 FPENSET 0 BPENSET
  717.  
  718.    ."  Every aspect of your text display is associated with a HeliOS stream."
  719.  
  720.    5 16 CURPUT
  721.  
  722.    ."  HeliOS remembers many details of the text format within each stream,"
  723.  
  724.    5 18 CURPUT
  725.  
  726.    ."  and allows you to switch streams effortlessly with a SINGLE word."
  727.  
  728.    5 21 CURPUT
  729.  
  730.    ."  Let's set up some streams and output some text into them now."
  731.  
  732.    5 24 CURPUT
  733.  
  734.    WAIT
  735.  
  736.    INIT3STREAMS                   \ Set up 3 streams
  737.  
  738.    1 STREAM DEMOTEXT1
  739.    2 STREAM DEMOTEXT1
  740.    3 STREAM DEMOTEXT1
  741.  
  742.    2 STREAM                       \ Central screen output stream
  743.  
  744.    CURHM 7 SCRDN                  \ Scroll text down 7 lines
  745.  
  746.    5 3 CURPUT
  747.  
  748.    ."  Here the screen has been split into three text streams."
  749.  
  750.    5 5 CURPUT
  751.  
  752.    WAIT
  753.  
  754.    SCRCLR
  755.  
  756.    1 FPENSET
  757.  
  758.    5 3 CURPUT
  759.  
  760.    ."  Let's open up the text display to the full window area now."
  761.  
  762.    5 5 CURPUT
  763.  
  764.    ."  We can also do some other tricks with text, as we shall see."
  765.  
  766.    5 9 CURPUT
  767.  
  768.    WAIT
  769.  
  770.    5 DUP INITSTREAM STREAM        \ Enter and initialise stream number 5
  771.  
  772.    CUROFF                         \ Switch off cursor
  773.  
  774.    2 BPENSET  1 FPENSET           \ Set colours
  775.  
  776.    2 CLEARWINDOWTOP
  777.  
  778.    SCRCLR                         \ Clear Stream text area
  779.  
  780.    DEMOTEXT1                      \ Fill stream window with text
  781.  
  782.    CURHM 10 SCRDN                 \ Make space at top of text
  783.  
  784.    5 2 CURPUT
  785.  
  786.    ."  This text stream fills the whole window."
  787.  
  788.    5 4 CURPUT
  789.  
  790.    ."  We have also set up plain text, in black, on a white background."
  791.  
  792.    5 6 CURPUT
  793.  
  794.    ."  Now we can set up some more streams with smaller text windows."
  795.  
  796.    5 9 CURPUT
  797.  
  798.    WAIT
  799.  
  800.    6 DUP INITSTREAM STREAM        \ Enter stream number 6 and initialise
  801.  
  802.    CUROFF
  803.  
  804.    3 BPENSET  2 FPENSET
  805.  
  806.    2 17 39 5  SCRWIN              \ Set up stream text output window
  807.  
  808.    BOLDON                         \ Set Bold text
  809.  
  810.    SCRCLR  1CR                    \ Clear stream window
  811.  
  812.    ."  This text stream has different colours .....and Bold text."
  813.  
  814.    WAITSPACE
  815.  
  816.    7 DUP INITSTREAM STREAM        \ Enter stream number 7 and initialise
  817.  
  818.    CUROFF
  819.  
  820.    7 BPENSET  3 FPENSET
  821.  
  822.    8 24 55 5  SCRWIN
  823.  
  824.    SCRCLR  1CR
  825.  
  826.    ULINEON                        \ Set underlined text
  827.  
  828.    ."  This stream has underlined text,"
  829.  
  830.    2CR
  831.  
  832.    ."  and different colours again."
  833.  
  834.    WAITSPACE
  835.  
  836.  
  837.    8 DUP INITSTREAM STREAM        \ Enter stream number 8 and initialise
  838.  
  839.    CUROFF
  840.  
  841.    0 BPENSET  3 FPENSET
  842.  
  843.    40 11 37 6  SCRWIN
  844.  
  845.    SCRCLR 1CR
  846.  
  847.    ."  And this is yet another variation."
  848.  
  849.    2CR
  850.  
  851.    ."  You have many choices, to make your"
  852.  
  853.    1CR
  854.  
  855.    ."  text more attractive."
  856.  
  857.    WAITSPACE
  858.  
  859.    5 STREAM
  860.  
  861.    SCRCLR
  862.  
  863.    5 3 CURPUT
  864.  
  865.    ."  You can have ten different uniquely formatted streams simultaneously."
  866.  
  867.    5 5 CURPUT
  868.  
  869.    ."  Each stream can have its own text styles and mini scrolling text window."
  870.  
  871.    5 7 CURPUT
  872.  
  873.   ."  All the Amiga console functions are supported, with additional features."
  874.  
  875.  
  876.    4 10 CURPUT  \ Set up another colour contrasted area
  877.  
  878.    BOLDON 3 FPENSET 2 BPENSET
  879.  
  880.    ."                                                                          "
  881.  
  882.    4 11 CURPUT
  883.  
  884.    ."   The system automatically remembers all the features of each stream.    "
  885.  
  886.    4 12 CURPUT
  887.  
  888.    ."                                                                          "
  889.  
  890.    4 13 CURPUT
  891.  
  892.    ."   Powerful text control is available with minimum programming effort.    "
  893.  
  894.    4 14 CURPUT
  895.  
  896.    ."                                                                          "
  897.  
  898.  
  899.    5 17 CURPUT  BOLDOFF 1 FPENSET 2 BPENSET
  900.  
  901.    ."  Now perhaps we can try outputting text to each of our new streams."
  902.  
  903.    5 20 CURPUT
  904.  
  905.    ."  First we shall send the whole block of text to each stream in turn,"
  906.  
  907.    5 22 CURPUT
  908.  
  909.    ."  and then try sending the text to all the streams line by line."
  910.  
  911.    5 24 CURPUT
  912.  
  913.    ."  Let's see what happens."
  914.  
  915.    5 27 CURPUT
  916.  
  917.    WAIT
  918.  
  919.    SCRCLR
  920.  
  921.    DEMOTEXT1
  922.  
  923.    6 STREAM SCRCLR DEMOTEXT1
  924.    7 STREAM SCRCLR DEMOTEXT1
  925.    8 STREAM SCRCLR DEMOTEXT1
  926.  
  927.    DEMOTEXT2
  928.  
  929.    9 DUP INITSTREAM STREAM
  930.  
  931.    CUROFF
  932.  
  933.    0 BPENSET 3 FPENSET
  934.  
  935.    7 6 67 18  SCRWIN
  936.  
  937.    SCRCLR
  938.  
  939.    2 3 CURPUT
  940.  
  941.    ."  The Helios text output formatting system can be set up"
  942.  
  943.    2 5 CURPUT
  944.  
  945.    ."  in any window, on any screen, with a SINGLE command!"
  946.  
  947.    2 8 CURPUT
  948.  
  949.    ."  HeliOS provides a large number of useful specialised text"
  950.  
  951.    2 10 CURPUT
  952.  
  953.    ."  formatting functions, which make sophisticated text oriented"
  954.  
  955.    2 12 CURPUT
  956.  
  957.    ."  programs very quick and easy to write."
  958.  
  959.    2 16 CURPUT
  960.  
  961.    WAIT
  962.  
  963.    SCRCLR
  964.  
  965.    6 2 CURPUT BOLDON 2 FPENSET 3 BPENSET
  966.  
  967.    ."                                                          "
  968.  
  969.    6 3 CURPUT
  970.  
  971.    ."    Would you like to experiment with the text colours?   "
  972.  
  973.    6 4 CURPUT
  974.  
  975.    ."                                                          "
  976.  
  977.    2 6 CURPUT BOLDOFF 3 FPENSET 0 BPENSET
  978.  
  979.    ."  Press <C> to step through colours, <X> to reset default values."
  980.  
  981.    2 8 CURPUT
  982.  
  983.    ."  The display shows which colour is currently being adjusted."
  984.  
  985.    2 10 CURPUT
  986.  
  987.    ."  Tap, or hold down, the <R>, <G>, and <B> keys to alter"
  988.  
  989.    2 12 CURPUT
  990.  
  991.    ."  the Red, Green, and Blue components of your chosen colour."
  992.  
  993.    33 17 CURPUT
  994.  
  995.    6 FPENSET
  996.  
  997.    ."  Press space to continue........"
  998.  
  999.    3 14 CURPOS
  1000.  
  1001.    ' NOOP CFA EXTERNAL !
  1002.  
  1003.    2 FPENSET 3 BPENSET 8 DEMOCOLOURS
  1004.    ;
  1005.  
  1006.  \ ----------------------------------------------------------------------------
  1007.  
  1008.  ( The word which controls progress through the Graphics Demo, allowing
  1009.    the user to either play around with the colours or carry on.
  1010.  
  1011.    The word DEMOWAIT does the serious work of adjusting colours etc. )
  1012.  
  1013.  
  1014.    : COLOURWAIT   ( - - - )    \ Wait for colour change or <Space>
  1015.  
  1016.    8 STREAM                    \ Lower right corner of screen = stream 8
  1017.  
  1018.    2 4 CURPUT ." Press <SPACE> to continue ...."
  1019.  
  1020.    7 STREAM CURHM              \ Lower left corner of screen = stream 7
  1021.  
  1022.    DEMOCOLOURS                 \ Allows colour change,
  1023.                                \ runs demo loop,
  1024.                                \ waits for <Space>
  1025.  
  1026.    8 STREAM                    \ Returns to stream 8
  1027.    ;
  1028.  
  1029.  \ ----------------------------------------------------------------------------
  1030.  
  1031.    ( Set up window handle storage variables etc. for "Window" demo )
  1032.  
  1033.    0.    DVARIABLE    WINDOW1
  1034.    0.    DVARIABLE    WINDOW2
  1035.    0.    DVARIABLE    WINDOW3
  1036.  
  1037.    280    VARIABLE    X1
  1038.    80     VARIABLE    Y1
  1039.    0      VARIABLE    X2
  1040.    0      VARIABLE    Y2
  1041.    0      VARIABLE    X3
  1042.    0      VARIABLE    Y3
  1043.  
  1044.    60     VARIABLE    RADIUS
  1045.    0      VARIABLE    ANGLE
  1046.  
  1047.  \ ---------------------------------------------------------------------------
  1048.  
  1049.  ( Moves window through a circular path )
  1050.  
  1051.    : TURNWINDOW      ( - - - )                 \ Move window in circle
  1052.  
  1053.    WINDOW2 D@   MAKEOUTWINDOW   CUROFF         \ Set text output to Window2
  1054.  
  1055.    12 0                                        \ Loop 12 times
  1056.  
  1057.    DO                                          \ Start loop
  1058.  
  1059.      WINDOW2 D@                                \ Get window handle
  1060.  
  1061.      X1 @                                      \ Calculate new X position
  1062.      DUP  RADIUS @ ANGLE @ GFXSIN 15 *ASR +
  1063.      DUP X1 ! -
  1064.  
  1065.      Y1 @                                      \ Calculate new Y position
  1066.      DUP  RADIUS @ ANGLE @ GFXCOS 15 *ASR 2/ +
  1067.      DUP Y1 ! -
  1068.  
  1069.      MOVEWINDOW                                \ Move window to new position
  1070.  
  1071.      30 ANGLE +!                               \ Update Angle
  1072.  
  1073.      7 RND 7 RND                               \ Random colours
  1074.      DDUP =                                    \ Are both colours the same?
  1075.      IF                                        \ If so, drop and ....
  1076.        DDROP 1 0                               \ .....use 1 and 0 instead
  1077.      THEN
  1078.  
  1079.      FPENSET BPENSET SCRCLR  DEMOTEXT1         \ Output some text
  1080.  
  1081.    LOOP                                        \ End 12 times loop
  1082.    ;
  1083.  
  1084.  \ ----------------------------------------------------------------------------
  1085.  
  1086.    ( A Windows demo
  1087.  
  1088.      This code is not very stylish, and although not as long as the
  1089.      earlier text demo it is still a little messy.
  1090.  
  1091.      This section is around 100 lines long, and is just about manageable
  1092.      because it lacks any serious logic and is a very simple piece of
  1093.      linear progression.
  1094.  
  1095.      The real problem here, and in the earlier text demo, is that the
  1096.      in-line text spoils the readability of the code.
  1097.  
  1098.      If you write a serious text based application you would need to
  1099.      create some scheme whereby text was stored neatly in external memory
  1100.      and referred to by pointers within your code.
  1101.  
  1102.      Notice how miscellaneous different methods of placing the cursor and
  1103.      setting the start of text lines have been used.
  1104.  
  1105.      Again this is quite "legal" but aesthetically nasty!
  1106.  
  1107.      Notice also that embedded in this code is the word TURNWINDOW which
  1108.      we defined earlier.
  1109.  
  1110.      But why DID we define TURNWINDOW separately?
  1111.  
  1112.      Usually we define short words like this for various reasons:
  1113.  
  1114.      1. Because they are used often, and defining them as a words allows
  1115.         them to be used repeatedly without including all the code each time.
  1116.  
  1117.      2. They form a neat logical functional unit which is easy to debug and
  1118.         maintain, and which may require change without interfering with the
  1119.         main program code.
  1120.  
  1121.      3. We simply want to break down a long section of code into sub-units
  1122.         for purposes of readability and maintenance.
  1123.  
  1124.      In this case reason 3 is closest, because we don't use TURNWINDOW
  1125.      anywhere else, and we won't really need to change it or play around
  1126.      with it later.
  1127.  
  1128.      However, if we have used this strategy with TURNWINDOW, why have we
  1129.      not broken down the rest of the code in a similar fashion?
  1130.  
  1131.      You may think all this is unimportant, but once you start writing
  1132.      large programs the way you organise your code is going to make a vast
  1133.      difference to how easy it is to debug, modify, and maintain. )
  1134.  
  1135.  
  1136.    : WINDOWSDEMO    ( - - - )
  1137.  
  1138.  
  1139.    9 DUP INITSTREAM STREAM                        \ Use stream 9 this time
  1140.  
  1141.    CUROFF 0 BPENSET 3 FPENSET                     \ Set cursor and colours
  1142.  
  1143.    0 CLEARWINDOWTOP                               \ Clear top of window
  1144.  
  1145.    SCRCLR    1 3 CURPUT                           \ Clear screen etc.
  1146.  
  1147.    ."      So far we have only operated within the main HeliOS display window,"
  1148.  
  1149.    1CR
  1150.  
  1151.    ."      but we can very easily create other windows, or indeed new screens."
  1152.  
  1153.    3CR   BOLDON   2 FPENSET   1 BPENSET   BOLDON    4 CURFW
  1154.  
  1155.    ."  The Helios system does all the tedious work involved in creating new "
  1156.  
  1157.    1CR   4 CURFW
  1158.  
  1159.    ."  screens or windows automatically, leaving you free to be creative.   "
  1160.  
  1161.    3CR   BOLDOFF   0 BPENSET   3 FPENSET
  1162.  
  1163.    ."      Your programming effort can be reduced to as little as entering only"
  1164.  
  1165.    1CR
  1166.  
  1167.    ."      ONE word for operations which would require a lot of code in other Amiga"
  1168.  
  1169.    1CR
  1170.  
  1171.    ."      languages.  HeliOS even keeps track of what Amiga resources you use, so"
  1172.  
  1173.    1CR
  1174.  
  1175.    ."      when you quit HeliOS everything is automatically closed down for you. "
  1176.  
  1177.    3CR   2 FPENSET   1 BPENSET   BOLDON   4 CURFW
  1178.  
  1179.    ."  It is absolutely simple to create windows, to appear on any screen,  "
  1180.  
  1181.    1CR   4 CURFW
  1182.  
  1183.    ."  and to do any kind of Input or Output using any Helios function.     "
  1184.  
  1185.    3CR
  1186.  
  1187.    BOLDOFF   0 BPENSET   3 FPENSET
  1188.  
  1189.  
  1190.    ."      Let's make a few windows now, and output some text to them."
  1191.  
  1192.    2CR
  1193.  
  1194.    ."      For now your input will still be via the main HeliOS display window,"
  1195.  
  1196.    1CR
  1197.  
  1198.    ."      so make sure that this main window is active before pressing <SPACE>."
  1199.  
  1200.    2CR   4 CURFW   WAIT   SCRCLR
  1201.  
  1202.    STDWINDOW HFWINDOW
  1203.  
  1204.    2 1 WINCOLS WINQUIET
  1205.    LIT$ DEMO WINDOW 1$    40  30  256 125  3 0  OPENWINDOW  WINDOW1 D!
  1206.  
  1207.    7 3 WINCOLS WINQUIET
  1208.    LIT$ DEMO WINDOW 2$    280 80  200 85   3 0  OPENWINDOW  WINDOW2 D!
  1209.  
  1210.    2 6 WINCOLS WINQUIET
  1211.    LIT$ DEMO WINDOW 3$    360 120 256 85   3 0  OPENWINDOW  WINDOW3 D!
  1212.  
  1213.    WINDOW1 D@ MAKEOUTWINDOW  1 BPENSET 2 FPENSET  CUROFF  DEMOTEXT1
  1214.    WINDOW2 D@ MAKEOUTWINDOW  3 BPENSET 7 FPENSET  CUROFF  DEMOTEXT1
  1215.    WINDOW3 D@ MAKEOUTWINDOW  2 BPENSET 3 FPENSET  CUROFF  DEMOTEXT1
  1216.  
  1217.    FORTHOUTWINDOW
  1218.    4 21 40 6 SCRWIN
  1219.    3 BPENSET 2 FPENSET
  1220.    SCRCLR
  1221.    1CR
  1222.  
  1223.    ."  We can also move windows around."
  1224.  
  1225.    2CR    WAIT   SCRCLR   2CR
  1226.  
  1227.    ."  Watch what happens ........"
  1228.  
  1229.    TURNWINDOW
  1230.  
  1231.    FORTHOUTWINDOW   SCRCLR   1CR
  1232.  
  1233.    ."  We can move windows in front of .....   or behind each other."
  1234.  
  1235.    2CR    WAIT   SCRCLR   2CR
  1236.  
  1237.    ."  Watch what happens ........"
  1238.  
  1239.    WINDOW1 D@ WINDOWTOBACK  50 DELAY
  1240.    WINDOW2 D@ WINDOWTOBACK  50 DELAY
  1241.    WINDOW3 D@ WINDOWTOBACK  50 DELAY
  1242.    WINDOW1 D@ WINDOWTOFRONT 50 DELAY
  1243.    WINDOW2 D@ WINDOWTOFRONT 50 DELAY
  1244.    WINDOW3 D@ WINDOWTOFRONT 50 DELAY
  1245.    WINDOW1 D@ WINDOWTOFRONT 50 DELAY
  1246.    WINDOW2 D@ WINDOWTOFRONT 50 DELAY
  1247.    WINDOW3 D@ WINDOWTOFRONT 50 DELAY
  1248.  
  1249.  
  1250.    FORTHOUTWINDOW   SCRCLR   1CR
  1251.  
  1252.    ."  Let's close these windows now."
  1253.  
  1254.    2CR      WAIT   SCRCLR
  1255.  
  1256.  
  1257.    WINDOW1 D@ CLOSEWINDOW
  1258.    WINDOW2 D@ CLOSEWINDOW
  1259.    WINDOW3 D@ CLOSEWINDOW
  1260.    ;
  1261.  
  1262.  \ ----------------------------------------------------------------------------
  1263.  
  1264.  ( Clear GFX window display area to colour )
  1265.  
  1266.    : CANVAS  ( colour - - - )        \ Clear area including top line
  1267.  
  1268.    GFXSETAPEN
  1269.  
  1270.    4 13 635 214 GFXRECTFILL ;
  1271.  
  1272.    : CANVAS2 ( colour - - - )        \ Clear are excluding top line
  1273.  
  1274.    GFXSETAPEN
  1275.  
  1276.    4 24 635 214 GFXRECTFILL ;
  1277.  
  1278.  \ ----------------------------------------------------------------------------
  1279.  
  1280.  ( Clip pixel write coordinates to screen drawing area )
  1281.  
  1282.    : GFXLIMITWRITE      ( X, Y - - - )
  1283.  
  1284.    OVER 4 635 WITHIN
  1285.    IF
  1286.      DUP 26 212 WITHIN
  1287.      IF
  1288.        GFXWRITE
  1289.      ELSE
  1290.        DDROP
  1291.      THEN
  1292.    ELSE
  1293.      DDROP
  1294.    THEN
  1295.    ;
  1296.  
  1297.  ( Pixel write Spriral Galaxy Demo )
  1298.  
  1299.    : GALAXY    ( - - - )    \ Draw a spiral of "semi-random" pixels
  1300.  
  1301.    0 0 GFXORIGIN
  1302.    1500 0
  1303.    DO
  1304.  
  1305.      7 RNDX  GFXSETAPEN
  1306.      I I GFXCOS 20000 */ 3 ASR 300 + DUP  24 RND +
  1307.      I I GFXSIN 32767 */ 4 ASR 100 + TUCK 12 RND +        GFXLIMITWRITE
  1308.  
  1309.      7 RNDX  GFXSETAPEN
  1310.      10 RND UNDER+
  1311.      5  RND +                                             GFXLIMITWRITE
  1312.  
  1313.      7 RND  GFXSETAPEN   632 RND 4 +     200 RND 11 +     GFXLIMITWRITE
  1314.      2      GFXSETAPEN   632 RND 4 +     200 RND 11 +     GFXLIMITWRITE
  1315.  
  1316.      3
  1317.    +LOOP
  1318.    ;
  1319.  
  1320.  \ ---------------------------------------------------------------------------
  1321.  
  1322.  ( Implements Galaxy Demo in COLOURWAIT loop )
  1323.  
  1324.    : GALAXYDEMO   ( c - - - c )
  1325.  
  1326.    ASCII m OVER=
  1327.    IF
  1328.      GALAXY
  1329.    THEN
  1330.    ;
  1331.  
  1332.  \ ----------------------------------------------------------------------------
  1333.  
  1334.  ( Displays Galaxy Demo )
  1335.  
  1336.    : SHOWGALAXY    ( - - - )
  1337.  
  1338.    1 CLEARWINDOWTOP
  1339.    5 STREAM
  1340.    1 BPENSET 2 FPENSET
  1341.    SCRCLR
  1342.    20 1 CURPUT
  1343.    ." Spiral Galaxy   8-Colour Pixel Write Demo"
  1344.  
  1345.    GALAXY
  1346.  
  1347.    8 COLOURWAIT
  1348.    ;
  1349.  
  1350.  \ ----------------------------------------------------------------------------
  1351.  
  1352.    ( Some variables for the 16 colour Mandelbrot demo. )
  1353.  
  1354.    0.     DVARIABLE SCREEN1
  1355.    3230   VARIABLE  P
  1356.    425    VARIABLE  Q
  1357.    0      VARIABLE  PP
  1358.    0      VARIABLE  QQ
  1359.    0      VARIABLE  X
  1360.    0      VARIABLE  Y
  1361.    0      VARIABLE  MANP
  1362.    0      VARIABLE  MANQ
  1363.    0      VARIABLE  INITIAL
  1364.  
  1365.  \ ----------------------------------------------------------------------------
  1366.  
  1367.    ( Set the 16 "Mandelbrot" screen colours )
  1368.  
  1369.    : SET16COLS    ( - - - )
  1370.  
  1371.    0  0  0  0   GFXSETRGB
  1372.    1  15 14 2   GFXSETRGB
  1373.    2  15 15 15  GFXSETRGB
  1374.    3  15 12 2   GFXSETRGB
  1375.    4  15 2  2   GFXSETRGB
  1376.    5  14 2  2   GFXSETRGB
  1377.    6  12 2  2   GFXSETRGB
  1378.    7  10 2  2   GFXSETRGB
  1379.    8  8  2  2   GFXSETRGB
  1380.    9  7  2  2   GFXSETRGB
  1381.    10 6  2  2   GFXSETRGB
  1382.    11 5  2  2   GFXSETRGB
  1383.    12 4  2  2   GFXSETRGB
  1384.    13 3  2  2   GFXSETRGB
  1385.    14 2  2  2   GFXSETRGB
  1386.    15 15 14 2   GFXSETRGB
  1387.    ;
  1388.  
  1389.  \ ----------------------------------------------------------------------------
  1390.  
  1391.    ( Open the 16 colour "Mandelbrot" screen and window )
  1392.  
  1393.    : GFX16COLWINDOW   ( - - - )
  1394.  
  1395.    1 STDSCREEN
  1396.  
  1397.    0 2 SCRCOLS
  1398.  
  1399.    LIT$ HeliOS                 ***<< Demo 16-Colour Screen >>***$
  1400.  
  1401.    640 256 4 OPENSCREEN
  1402.  
  1403.    SCREEN1 D!
  1404.  
  1405.    STDWINDOW HFWINDOW
  1406.  
  1407.    SCREEN1 D@ WINDOWSTRUCT 30 + D!
  1408.  
  1409.    0 2 WINCOLS
  1410.  
  1411.    LIT$ HeliOS                 ***<< Demo 16-Colour Window >>***$
  1412.  
  1413.    0 11   640 237   4 0  OPENWINDOW
  1414.  
  1415.    WINDOW1 D!
  1416.  
  1417.    WINDOW1 D@ MAKEGFXWINDOW
  1418.  
  1419.    SET16COLS ;
  1420.  
  1421.  \ ----------------------------------------------------------------------------
  1422.  
  1423.    ( Set up the 16 colour "Mandelbrot" window graphic lines )
  1424.  
  1425.    : DIVIDERS   ( - - - )
  1426.  
  1427.    5 GFXSETAPEN
  1428.  
  1429.    320 10 GFXMOVE   320 194 GFXDRAW
  1430.    319 10 GFXMOVE   319 194 GFXDRAW
  1431.    0  169 GFXMOVE   639 169 GFXDRAW
  1432.    0  194 GFXMOVE   639 194 GFXDRAW
  1433.    ;
  1434.  
  1435.  \ ----------------------------------------------------------------------------
  1436.  
  1437.   ( Set up streams and text for Mandelbrot demo )
  1438.  
  1439.   : MANDELSTREAMS  ( - - - )
  1440.  
  1441.  
  1442.   WINDOW1 D@ MAKEOUTWINDOW CUROFF
  1443.  
  1444.   2 FPENSET 0 BPENSET
  1445.  
  1446.   14 22  CURPUT  ." JULIA SET DEMO"
  1447.  
  1448.   51 22  CURPUT  ." MANDELBROT SET DEMO"
  1449.  
  1450.   7 DUP INITSTREAM STREAM CUROFF 1 FPENSET 0 BPENSET
  1451.  
  1452.   1 24  30 4 SCRWIN
  1453.  
  1454.   8 DUP INITSTREAM STREAM CUROFF 5 FPENSET 0 BPENSET
  1455.  
  1456.   31 24 49 4 SCRWIN
  1457.  
  1458.   7 STREAM SCRCLR 8 STREAM SCRCLR
  1459.   ;
  1460.  
  1461.  \ ----------------------------------------------------------------------------
  1462.  
  1463.    ( Now a bit of HeliOS Assembler for you to have fun with! )
  1464.  
  1465.    CODE MANDCALC                            ( PP QQ SC - - - C )
  1466.  
  1467.    WORD                                     \ Set assembler size
  1468.  
  1469.    FSP ()+ D5 MOVE                          \ Unload scaling factor > D5
  1470.  
  1471.    FSP ()+ D4 MOVE                          \ Unload Y > D4
  1472.  
  1473.    FSP ()+ D3 MOVE                          \ Unload X > D3
  1474.  
  1475.    63 # D2 MOVE                             \ Set loop index D2 = 63
  1476.  
  1477.    D2 DO                                    \ Initiate loop with D2 as index
  1478.  
  1479.    D3 D6 MOVE                               \ Store old X (D3) value
  1480.  
  1481.    D3 D0 MOVE                               \ Calculate scaled X*X
  1482.    D3 D0 MULS
  1483.    LONG D5 D0 ASR WORD                      \ ( D3*D3  11 ASR > D0 )
  1484.  
  1485.    D4 D1 MOVE                               \ Calculate scaled Y*Y
  1486.    D4 D1 MULS
  1487.    LONG D5 D1 ASR WORD                      \ ( D4*D4  11 ASR > D1 )
  1488.  
  1489.    2 FSP D() D3 MOVE                        \ X*X - Y*Y + P (= new X) > D3
  1490.    D0        D3 ADD
  1491.    D1        D3 SUB                         \ ( D0 - D1 + PP  > D3 )
  1492.  
  1493.    LONG D1 D0 ADD WORD                      \ LONG add D1 to D0 for limit
  1494.  
  1495.    D4 D1 MOVE                               \ X*Y/2 >D1
  1496.    D6 D1 MULS
  1497.    LONG 1 # D1 LSL D5 D1 ASR  WORD          \ D6*D4  10 ASR > D1
  1498.  
  1499.    FSP () D4 MOVE                           \ X*Y/2 + Q (=new Y) > D4
  1500.    D1     D4 ADD                            \ (  D1 + QQ > D4 )
  1501.  
  1502.    LONG 180000. # D0 CMP WORD               \ ? D0 (=limit) > 180000
  1503.  
  1504.    DBGT                                     \ Loop
  1505.  
  1506.    0< IF 0 # D2 MOVE THEN                   \ ? Reached loop limit
  1507.  
  1508.    2 # D2 LSR                               \ Scale iteration count
  1509.  
  1510.    4 # FSP ADDA                             \ Clear stack
  1511.  
  1512.    D2 FSP -() MOVE                          \ Colour (0-15) > stack
  1513.  
  1514.    EXITCODE
  1515.  
  1516.    ENDCODE
  1517.  
  1518.  \ ---------------------------------------------------------------------------
  1519.  
  1520.    ( Here we go with the Julia set code.
  1521.  
  1522.      If you don't understand it, don't worry about it! )
  1523.  
  1524.    : JULIA  ( - - - )
  1525.  
  1526.    2 11 GFXORIGIN
  1527.  
  1528.    3230 512 10000 */ PP !
  1529.    425  512 10000 */ QQ !
  1530.  
  1531.    158 0
  1532.    DO
  1533.      317 0
  1534.      DO
  1535.  
  1536.        PP @ QQ @
  1537.  
  1538.        I  2 LSL 640 -
  1539.        J  3 LSL 640 -
  1540.        9   MANDCALC
  1541.  
  1542.        DUP
  1543.        IF
  1544.          26 SWAP -
  1545.        THEN
  1546.  
  1547.        DUP 15 >
  1548.        IF
  1549.          13 -
  1550.        THEN
  1551.  
  1552.        DUP 12 =
  1553.        IF
  1554.          DROP 8
  1555.        THEN
  1556.  
  1557.        DUP 14 =
  1558.        IF
  1559.          DROP 3
  1560.        THEN
  1561.  
  1562.        GFXSETAPEN
  1563.        I J GFXWRITE
  1564.      LOOP
  1565.    LOOP
  1566.    ;
  1567.  
  1568.  \ ---------------------------------------------------------------------------
  1569.  
  1570.   ( Now for the Mandebrot.
  1571.  
  1572.    Anyone understand this?
  1573.  
  1574.    Don't worry about it!
  1575.  
  1576.    But it is simple isn't it! )
  1577.  
  1578.    : MANDEL  ( - - - )
  1579.  
  1580.    -.5777777  10000 M/  8883608. 1000 M/ 12 *ASR   MANP !
  1581.    -.6370000  10000 M/  8883608. 1000 M/ 12 *ASR   MANQ !
  1582.  
  1583.    321 11 GFXORIGIN
  1584.  
  1585.    158 0
  1586.    DO
  1587.      317 0
  1588.      DO
  1589.  
  1590.        I   2/  MANP @  +                \ P value
  1591.        J       MANQ @  +                \ Q value
  1592.        0                                \ X value
  1593.        0                                \ Y value
  1594.        11                               \ Scaling value
  1595.  
  1596.        MANDCALC
  1597.  
  1598.        GFXSETAPEN I J GFXWRITE
  1599.  
  1600.      LOOP
  1601.    LOOP
  1602.    ;
  1603.  
  1604.  \ ---------------------------------------------------------------------------
  1605.  
  1606.    ( Run the MandeBrot and Julia demo )
  1607.  
  1608.    : MANDELDEMO  ( - - - )
  1609.  
  1610.    JULIA
  1611.    MANDEL
  1612.    ;
  1613.  
  1614.  \ ---------------------------------------------------------------------------
  1615.  
  1616.    ( Close the MandeBrot and Julia demo )
  1617.  
  1618.   : MANDELEND  ( - - - )
  1619.  
  1620.    FORTHINWINDOW FORTHOUTWINDOW
  1621.  
  1622.    FWINDOW MAKEGFXWINDOW
  1623.  
  1624.    WINDOW1 D@ CLOSEWINDOW
  1625.  
  1626.    SCREEN1 D@ CLOSESCREEN
  1627.    ;
  1628.  
  1629.  \ ---------------------------------------------------------------------------
  1630.  
  1631.   ( Introduce and show Mandelbrot Pictures )
  1632.  
  1633.   : DOMANDEL
  1634.  
  1635.   2 CANVAS
  1636.   7 STREAM SCRCLR 8 STREAM SCRCLR 6 STREAM SCRCLR
  1637.  
  1638.  ."  The next part of the Demo opens a new 16-Colour Screen and Window."
  1639.   1CR
  1640.  ."  You will find that this is an extremely simple operation in HeliOS."
  1641.   2CR
  1642.  ."  The 16-Colour Demo will involve COMPUTING and drawing two pictures which"
  1643.   1CR
  1644.  ."  derive from the Mandelbrot Set. ( One is actually a related Julia Set )"
  1645.   2CR
  1646.  ."  These pictures do take a considerable time to compute, but they actually"
  1647.   1CR
  1648.  ."  show that HeliOS is very fast indeed, because they use only code"
  1649.   1CR
  1650.  ."  written using the high level HeliOS system for all computations."
  1651.   1CR
  1652.  ."  Dedicated Mandelbrot Set generators often employ code written using a"
  1653.   1CR
  1654.  ."  separate assembler to achieve reasonable speed. Obviously you could"
  1655.   1CR
  1656.  ."  do the same and gain even more performance, but the idea of the Demo is"
  1657.   1CR
  1658.  ."  to show the exceptional speed of the high level HeliOS system."
  1659.   2CR
  1660.  ."  This is good news for creative programmers, because at last you have"
  1661.   1CR
  1662.  ."  access to an Interactive high level software system which is fast enough"
  1663.   1CR
  1664.  ."  to cope with the most demanding applications."
  1665.   2CR
  1666.  ."  The other good news is that if you are interested in the Mandelbrot Set"
  1667.   1CR
  1668.  ."  you are now in a position to write your own customised software, building"
  1669.   1CR
  1670.  ."  on the basis of the Demo source code provided."
  1671.  
  1672.   8 COLOURWAIT
  1673.  
  1674.   0 STREAM 0 BPENSET 1 FPENSET SCRCLR
  1675.  
  1676.   ' NOOP  CFA EXTERNAL !
  1677.  
  1678.   GFX16COLWINDOW
  1679.  
  1680.   MANDELSTREAMS
  1681.  
  1682.   DIVIDERS
  1683.  
  1684.   8 STREAM
  1685.  
  1686.   2 1 CURPUT  ." These pictures involve intensive computation."
  1687.  
  1688.   2 2 CURPUT  ." Please wait for the images to complete......."
  1689.  
  1690.   2 3 CURPUT  ." ....when finished you can adjust the colours."
  1691.  
  1692.   MANDELDEMO
  1693.  
  1694.   SCRCLR
  1695.  
  1696.   WINDOW1 D@ MAKEINWINDOW
  1697.  
  1698.   16 COLOURWAIT
  1699.  
  1700.   MANDELEND
  1701.   ;
  1702.  
  1703.  \ ---------------------------------------------------------------------------
  1704.  
  1705.    ( Various variables used in calculating fractals )
  1706.  
  1707.    0      VARIABLE   LINERATIO
  1708.    0      VARIABLE   HEIGHTRATIO
  1709.    0      VARIABLE   WIDTHRATIO
  1710.    0      VARIABLE   LINELENGTH
  1711.    0      VARIABLE   RECDEPTH
  1712.    0      VARIABLE   NODE
  1713.  
  1714.    0      VARIABLE   X0
  1715.    0      VARIABLE   Y0
  1716.  
  1717.    0      VARIABLE   GRECDEPTH
  1718.    0      VARIABLE   GX
  1719.    0      VARIABLE   GY
  1720.    0      VARIABLE   GX1
  1721.    0      VARIABLE   GY1
  1722.    0      VARIABLE   GX2
  1723.    0      VARIABLE   GY2
  1724.    0      VARIABLE   GX3
  1725.    0      VARIABLE   GY3
  1726.    0      VARIABLE   GXA
  1727.    0      VARIABLE   GYA
  1728.    0      VARIABLE   GXB
  1729.    0      VARIABLE   GYB
  1730.    0      VARIABLE   GXC
  1731.    0      VARIABLE   GYC
  1732.    0      VARIABLE   GA
  1733.    0      VARIABLE   GL
  1734.    0      VARIABLE   GL*C
  1735.    0      VARIABLE   GL*S
  1736.  
  1737.    0      VARIABLE   DODRAW
  1738.    0      VARIABLE   DOMOVE
  1739.    0      VARIABLE   RECLIMIT
  1740.  
  1741.  \ ---------------------------------------------------------------------------
  1742.  
  1743.    ( Fractal demo scaled screen rendering routines )
  1744.  
  1745.    ' NOOP CFA VARIABLE TINT
  1746.  
  1747.    : SCALEMOVE   ( X, Y - - - )
  1748.  
  1749.    SWAP 6 ASR SWAP 7 ASR
  1750.    DOMOVE @EXECUTE
  1751.    ;
  1752.  
  1753.    : SCALEDRAW   ( X,Y - - - )
  1754.  
  1755.    TINT @EXECUTE
  1756.  
  1757.    SWAP 6 ASR SWAP 7 ASR
  1758.    DODRAW @EXECUTE
  1759.    ;
  1760.  
  1761.  \ ---------------------------------------------------------------------------
  1762.  
  1763.    ( Set area or line plot functions )
  1764.  
  1765.    : MAKEAREAPLOT
  1766.  
  1767.    ' GFXAREAMOVE  CFA DOMOVE !
  1768.    ' GFXAREADRAW  CFA DODRAW !
  1769.    ;
  1770.  
  1771.  
  1772.    : MAKELINEPLOT
  1773.  
  1774.    ' GFXMOVE  CFA DOMOVE !
  1775.    ' GFXDRAW  CFA DODRAW !
  1776.    ;
  1777.  
  1778.  \ ---------------------------------------------------------------------------
  1779.  
  1780.    ( Generate new coordinates from a line
  1781.  
  1782.      Don't bother trying to follow this......... )
  1783.  
  1784.    : GENERATE
  1785.  
  1786.    GRECDEPTH ! GY2 ! GX2 ! GY1 ! GX1 !    \ Unload line end Coords etc
  1787.  
  1788.    GX2 @ GX1 @ - GX !                     \ X dimension     > GX
  1789.    GY2 @ GY1 @ - GY !                     \ Y dimension     > GY
  1790.  
  1791.    GX @ DUP M* GY @ DUP M* D+ GFXDSQROOT  \ Sq root of (X*X + Y*Y)
  1792.  
  1793.    DUP RECLIMIT @  >
  1794.    IF
  1795.      GL !                                 \ Length of line  > GL
  1796.  
  1797.      GY @  ABS  0  15 DLSL   GL @ U/   GFXARCSIN GA !
  1798.  
  1799.      GX @ 0<   IF GY @ 0 >= IF  180 GA @ - GA ! THEN  THEN   \ Adj quadrant
  1800.  
  1801.      GX @ 0 <= IF GY @ 0<   IF  180 GA +!       THEN  THEN
  1802.  
  1803.      GX @ 0>   IF GY @ 0<   IF  360 GA @ - GA ! THEN  THEN
  1804.  
  1805.      GL @  GA @ GFXSIN 15 *ASR   GL*S !    \ Intermediate result
  1806.      GL @  GA @ GFXCOS 15 *ASR   GL*C !    \ Intermediate result
  1807.  
  1808.      90 GA +!                               \ Angle + 90 degrees
  1809.  
  1810.      LINERATIO @ GL*C @ 13 *ASR  GX1 @ + GX3 !
  1811.      LINERATIO @ GL*S @ 13 *ASR  GY1 @ + GY3 !
  1812.  
  1813.      LINERATIO @ WIDTHRATIO @ - DUP GL*C @ 13 *ASR GX1 @ + GXA !
  1814.                                     GL*S @ 13 *ASR GY1 @ + GYA !
  1815.  
  1816.      LINERATIO @ WIDTHRATIO @ + DUP GL*C @ 13 *ASR GX1 @ + GXB !
  1817.                                     GL*S @ 13 *ASR GY1 @ + GYB !
  1818.  
  1819.      HEIGHTRATIO @ GL @ 13 *ASR GA @ DDUP
  1820.                                     GFXCOS 15 *ASR GX3 @ + GXC !
  1821.                                     GFXSIN 15 *ASR GY3 @ + GYC !
  1822.  
  1823.  
  1824.      GRECDEPTH @ GY2 @ GX2 @ GYC @ GXC @ GYB @ GXB @ GYA @ GXA @ GY1 @ GX1 @
  1825.  
  1826.      NODE @EXECUTE
  1827.    ELSE
  1828.      DROP
  1829.    THEN
  1830.    ;
  1831.  
  1832.  \ ---------------------------------------------------------------------------
  1833.  
  1834.    ( Don't bother trying to follow this either! )
  1835.  
  1836.    : NODE1
  1837.  
  1838.    5 PICK  7 PICK  SCALEMOVE                 \ Draw sub-lines
  1839.    7 PICK  9 PICK  SCALEDRAW
  1840.    3PICK   5 PICK  SCALEDRAW    GFXAREAEND
  1841.  
  1842.    11 PICK IF                                \ Process sub-lines
  1843.  
  1844.    DUP     3PICK  5 PICK  7 PICK      15 PICK 1-  GENERATE
  1845.    3PICK  5 PICK  9 PICK 11 PICK      15 PICK 1-  GENERATE
  1846.    7 PICK 9 PICK  7 PICK  9 PICK      15 PICK 1-  GENERATE
  1847.    5 PICK 7 PICK 11 PICK 13 PICK      15 PICK 1-  GENERATE
  1848.  
  1849.    THEN  11 DROPS ;
  1850.  
  1851.  \ ---------------------------------------------------------------------------
  1852.  
  1853.    ( Don't bother trying to follow this either! )
  1854.  
  1855.    : NODE2
  1856.  
  1857.    11 PICK 0= IF
  1858.  
  1859.    DUP 3PICK       SCALEMOVE       7 PICK 9 PICK  SCALEDRAW
  1860.  
  1861.    9 PICK 11 PICK  SCALEDRAW           DUP 3PICK  SCALEDRAW
  1862.  
  1863.    GFXAREAEND
  1864.  
  1865.    ELSE
  1866.  
  1867.    7 PICK 9 PICK   3PICK  5 PICK 15 PICK 1- GENERATE
  1868.  
  1869.    7 PICK 9 PICK 11 PICK 13 PICK 15 PICK 1- GENERATE
  1870.  
  1871.    THEN 11 DROPS ;
  1872.  
  1873.  \ ---------------------------------------------------------------------------
  1874.  
  1875.    ( Don't bother trying to follow this either! )
  1876.  
  1877.     : NODE3
  1878.  
  1879.     11 PICK 0= IF
  1880.  
  1881.     DUP 3PICK       SCALEMOVE   7 PICK 9 PICK  SCALEDRAW
  1882.  
  1883.     9 PICK 11 PICK  SCALEDRAW       DUP 3PICK  SCALEDRAW
  1884.  
  1885.     GFXAREAEND
  1886.  
  1887.     ELSE
  1888.  
  1889.     DUP 3PICK       9 PICK 11 PICK    15 PICK 1-  GENERATE
  1890.  
  1891.     7 PICK 9 PICK   11 PICK 13 PICK   15 PICK 1-  GENERATE
  1892.  
  1893.     THEN 11 DROPS ;
  1894.  
  1895.  \ ---------------------------------------------------------------------------
  1896.  
  1897.  ( Colours for various fractal demos )
  1898.  
  1899.    : LANDCOL
  1900.  
  1901.    BEGIN
  1902.      7 RND DUP 2 =
  1903.    WHILE
  1904.      DROP
  1905.    REPEAT
  1906.    GFXSETAPEN
  1907.    ;
  1908.  
  1909.    : SNOWCOL1
  1910.  
  1911.    1 GFXSETAPEN
  1912.    ;
  1913.  
  1914.    : SNOWCOL2
  1915.  
  1916.    GRECDEPTH @ 3 AND DUP 2 =
  1917.    IF
  1918.      5 RND + 1+
  1919.    THEN
  1920.    GFXSETAPEN
  1921.    ;
  1922.  
  1923.  \ ---------------------------------------------------------------------------
  1924.  
  1925.   ( Snowflake Fractal )
  1926.  
  1927.    : SNOWFLAKE  ( - - - )
  1928.  
  1929.    ' SNOWCOL1   CFA      TINT !
  1930.    ' NODE1      CFA      NODE !
  1931.  
  1932.    4096                  LINERATIO   !
  1933.    2100     1600 RND +   HEIGHTRATIO !
  1934.    1800     1600 RND -   WIDTHRATIO  !
  1935.    3        4    RND +   RECDEPTH    !
  1936.    128                   RECLIMIT    !
  1937.    12800                 LINELENGTH  !
  1938.  
  1939.  
  1940.    LINELENGTH @ 60 GFXCOS 15 *ASR X3 !
  1941.    LINELENGTH @ 60 GFXSIN 15 *ASR Y3 !
  1942.  
  1943.    310 LINELENGTH @ 128 / -   120 Y3 @ 256 / -  GFXORIGIN
  1944.  
  1945.    X1 0!   Y1 0!       LINELENGTH @ X2 !  Y2 0!
  1946.  
  1947.    X1 @  Y1 @   SCALEMOVE          \ Draw Triangle
  1948.    X2 @  Y2 @   SCALEDRAW
  1949.    X3 @  Y3 @   SCALEDRAW
  1950.    X1 @  Y1 @   SCALEDRAW
  1951.  
  1952.    GFXAREAEND
  1953.  
  1954.    ' SNOWCOL2  CFA TINT !
  1955.  
  1956.    X3 @ Y3 @ X2 @ Y2 @ RECDEPTH @ GENERATE
  1957.    X2 @ Y2 @ X1 @ Y1 @ RECDEPTH @ GENERATE
  1958.    X1 @ Y1 @ X3 @ Y3 @ RECDEPTH @ GENERATE
  1959.    ;
  1960.  
  1961.  \ ---------------------------------------------------------------------------
  1962.  
  1963.   ( Landscape fractal )
  1964.  
  1965.    : LANDSCAPE    ( - - - )
  1966.  
  1967.    ' LANDCOL  CFA        TINT !
  1968.    ' NODE1    CFA        NODE !
  1969.  
  1970.    1600 2400 RND +       LINERATIO   !
  1971.    -1700 1700 RND -      HEIGHTRATIO !
  1972.    110 170 RND +         WIDTHRATIO  !
  1973.    5 4 RND +             RECDEPTH    !
  1974.    128                   RECLIMIT    !
  1975.    32000                 LINELENGTH  !
  1976.  
  1977.    316 LINELENGTH @ 128 / -    170 GFXORIGIN
  1978.  
  1979.  
  1980.    X1 0! Y1 0!               LINELENGTH @ X2 !  Y2 0!
  1981.  
  1982.    X1 @ Y1 @ SCALEMOVE
  1983.    X2 @ Y2 @ SCALEDRAW
  1984.    GFXAREAEND
  1985.  
  1986.    X1 @
  1987.    Y1 @
  1988.    X2 @
  1989.    Y2 @
  1990.    RECDEPTH @
  1991.    GENERATE
  1992.    ;
  1993.  
  1994.  \ ---------------------------------------------------------------------------
  1995.  
  1996.   ( Dragon Fractal )
  1997.  
  1998.    : DRAGON    ( - - - )
  1999.  
  2000.    ' LANDCOL  CFA     TINT !
  2001.    ' NODE2    CFA     NODE !
  2002.  
  2003.    3800  480 RND +    LINERATIO   !
  2004.    -3800  480 RND -   HEIGHTRATIO !
  2005.    3800 640 RND +     WIDTHRATIO  !
  2006.    10 2 RND +         RECDEPTH    !
  2007.    32                 RECLIMIT    !
  2008.    12800              LINELENGTH  !
  2009.  
  2010.    195 125            GFXORIGIN
  2011.  
  2012.    X1 0! Y1 0!        LINELENGTH @ X2 ! Y2 0!
  2013.  
  2014.    X1 @
  2015.    Y1 @
  2016.    X2 @
  2017.    Y2 @
  2018.    RECDEPTH @
  2019.    GENERATE
  2020.    ;
  2021.  
  2022.  \ ---------------------------------------------------------------------------
  2023.  
  2024.   ( C-Curve Fractal )
  2025.  
  2026.    : CCURVE   ( - - - )
  2027.  
  2028.    ' LANDCOL  CFA    TINT !
  2029.    ' NODE3    CFA    NODE !
  2030.  
  2031.    4096              LINERATIO   !
  2032.    -3900 350 RND -   HEIGHTRATIO !
  2033.    3900  350 RND +   WIDTHRATIO  !
  2034.    8 4 RND +         RECDEPTH    !
  2035.    32                RECLIMIT    !
  2036.    12800             LINELENGTH  !
  2037.  
  2038.    210 140           GFXORIGIN
  2039.  
  2040.    X1 0! Y1 0!       LINELENGTH @ X2 ! Y2 0!
  2041.  
  2042.    X1 @
  2043.    Y1 @
  2044.    X2 @
  2045.    Y2 @
  2046.    RECDEPTH @
  2047.    GENERATE
  2048.    ;
  2049.  
  2050.  \ ---------------------------------------------------------------------------
  2051.  
  2052.   ( Display Snowflake Demo )
  2053.  
  2054.    : SHOWSNOWFLAKE  ( - - - )
  2055.  
  2056.    2 CLEARWINDOWTOP
  2057.    5 STREAM
  2058.    2 BPENSET 1 FPENSET
  2059.    SCRCLR
  2060.    22 1 CURPUT
  2061.    ." Snowflake       8-Colour Fractal Demo"
  2062.  
  2063.    SNOWFLAKE
  2064.  
  2065.    8 COLOURWAIT
  2066.    ;
  2067.  
  2068.    : SNOWFLAKEDEMO   ( c - - - c )
  2069.  
  2070.    ASCII m OVER=
  2071.    IF
  2072.      2 CANVAS2
  2073.      SNOWFLAKE
  2074.    THEN
  2075.    ;
  2076.  
  2077.  \ ---------------------------------------------------------------------------
  2078.  
  2079.   ( Display Landscape Demo )
  2080.  
  2081.    : SHOWLANDSCAPE  ( - - - )
  2082.  
  2083.    2 CLEARWINDOWTOP
  2084.    5 STREAM
  2085.    2 BPENSET 1 FPENSET
  2086.    SCRCLR
  2087.    22 1 CURPUT
  2088.    ." LandScape       8-Colour Fractal Demo"
  2089.  
  2090.    LANDSCAPE
  2091.  
  2092.    8 COLOURWAIT
  2093.    ;
  2094.  
  2095.    : LANDSCAPEDEMO   ( c - - - c )
  2096.  
  2097.    ASCII m   OVER=
  2098.    IF
  2099.      2 CANVAS2
  2100.      LANDSCAPE
  2101.    THEN
  2102.    ;
  2103.  
  2104.  \ ---------------------------------------------------------------------------
  2105.  
  2106.   ( Display Dragon Demo )
  2107.  
  2108.    : SHOWDRAGON   ( - - - )
  2109.  
  2110.    2 CLEARWINDOWTOP
  2111.    5 STREAM
  2112.    2 BPENSET 1 FPENSET
  2113.    SCRCLR
  2114.    22 1 CURPUT
  2115.    ." Dragon          8-Colour Fractal Demo"
  2116.  
  2117.    DRAGON
  2118.  
  2119.    8 COLOURWAIT
  2120.    ;
  2121.  
  2122.    : DRAGONDEMO    ( c - - - c )
  2123.  
  2124.    ASCII m  OVER=
  2125.    IF
  2126.      2 CANVAS2
  2127.      DRAGON
  2128.    THEN
  2129.    ;
  2130.  
  2131.  \ ---------------------------------------------------------------------------
  2132.  
  2133.   ( Display C-Curve Demo )
  2134.  
  2135.    : SHOWCCURVE   ( - - - )
  2136.  
  2137.    2 CLEARWINDOWTOP
  2138.    5 STREAM
  2139.    2 BPENSET 1 FPENSET
  2140.    SCRCLR
  2141.    22 1 CURPUT
  2142.    ." C-Curve         8-Colour Fractal Demo"
  2143.  
  2144.    CCURVE
  2145.  
  2146.    8 COLOURWAIT
  2147.    ;
  2148.  
  2149.    : CCURVEDEMO   ( c - - - c )
  2150.  
  2151.    ASCII m  OVER=
  2152.    IF
  2153.      2 CANVAS2
  2154.      CCURVE
  2155.    THEN
  2156.    ;
  2157.  
  2158.   \ ---------------------------------------------------------------------------
  2159.  
  2160.   ( Graphics demo Introduction )
  2161.  
  2162.    : GFXINTRO     ( - - - )
  2163.  
  2164.    7 DUP INITSTREAM STREAM CUROFF 2 FPENSET 6 BPENSET
  2165.    1 26  30 4 SCRWIN SCRCLR
  2166.  
  2167.    8 DUP INITSTREAM STREAM CUROFF 2 FPENSET 3 BPENSET
  2168.    31 26 49 4 SCRWIN SCRCLR
  2169.  
  2170.    6 DUP INITSTREAM STREAM CUROFF 2 BPENSET 1 FPENSET
  2171.    3 3 76 22 SCRWIN
  2172.  
  2173.    5 DUP INITSTREAM STREAM CUROFF 2 BPENSET 1 FPENSET
  2174.    1 1 79 25 SCRWIN SCRCLR
  2175.  
  2176.    2CR
  2177.  
  2178.    ."    Look carefully at the way the present screen is organised, which"
  2179.  
  2180.    1CR
  2181.  
  2182.    ."    will be similar for all the Graphics Demonstrations."
  2183.  
  2184.    3CR 3 FPENSET
  2185.  
  2186.    ."    The Graphics Demonstrations themselves will occupy the upper window."
  2187.  
  2188.    3CR
  2189.  
  2190.    ."    All instructions will be presented in the lower right screen area."
  2191.  
  2192.    3CR 1 FPENSET
  2193.  
  2194.    .$    Whenever the "Press <SPACE>" or any other command option is indicated$
  2195.  
  2196.    1CR
  2197.  
  2198.    ."    in the lower right area, you will always have the additional option of"
  2199.  
  2200.    1CR
  2201.  
  2202.    ."    using the Colour adjustment keys to modify the displayed image."
  2203.  
  2204.    2CR
  2205.  
  2206.    ."    This will give you the freedom to enjoy creating new graphic effects"
  2207.  
  2208.    1CR
  2209.  
  2210.    ."    and exploring your own colour preferences."
  2211.  
  2212.    3CR
  2213.  
  2214.    8 COLOURWAIT
  2215.    ;
  2216.  
  2217.  
  2218.  \ ---------------------------------------------------------------------------
  2219.  
  2220.   ( Introduce and show Snowflake )
  2221.  
  2222.    :   DOSNOWFLAKE   ( - - - )
  2223.  
  2224.    6 STREAM SCRCLR
  2225.  
  2226.    .$  The first Fractal we shall produce is the well known "Koch Snowflake",$
  2227.    1CR
  2228.    ."  which builds its form on a triangular initial generator."
  2229.    2CR
  2230.    ."  You can use the <M> key to redraw the image, each new Snowflake being"
  2231.    1CR
  2232.    ."  constructed using different random parameters."
  2233.    2CR
  2234.    ."  Notice how the various patterns are generated by imposing a similar"
  2235.    1CR
  2236.    ."  deformation upon each of the lines which make up the design."
  2237.    2CR
  2238.    ."  Again the colour control keys can be used to experiment with different"
  2239.    1CR
  2240.    ."  colour combinations."
  2241.    2CR
  2242.    ."  By now you should be getting a feel for the way in which simple eight"
  2243.    1CR
  2244.    ."  colour displays can be combined in attractive mutually enhancing ways."
  2245.    2CR
  2246.    ."  N.B."
  2247.    1CR
  2248.    ."  This and the following Fractal designs have an ENORMOUS number of"
  2249.    1CR
  2250.    ."  possible random variations. It is well worth trying many versions of"
  2251.    1CR
  2252.    ."  each because amongst a run of fairly mundane examples suddenly, from"
  2253.    1CR
  2254.    ."  time to time, a really spectacular and beautiful design will emerge."
  2255.  
  2256.    8 COLOURWAIT
  2257.  
  2258.    ' SNOWFLAKEDEMO  CFA EXTERNAL !
  2259.  
  2260.    8 STREAM
  2261.  
  2262.    2 1 CURPUT   ." Try adjusting the colours."
  2263.  
  2264.    2 2 CURPUT   ." Press <M> to generate a new Snowflake."
  2265.  
  2266.    2 3 CURPUT   ." Notice how the forms subtly metamorphose."
  2267.  
  2268.    SHOWSNOWFLAKE
  2269.  
  2270.    ' NOOP  CFA EXTERNAL !
  2271.  
  2272.    8 STREAM SCRCLR
  2273.  
  2274.    6 STREAM SCRCLR
  2275.    ;
  2276.  
  2277.  \ ---------------------------------------------------------------------------
  2278.  
  2279.   ( Introduce and show Galaxy )
  2280.  
  2281.    : DOGALAXY   ( - - - )
  2282.  
  2283.    2 CANVAS 6 STREAM CURHM
  2284.  
  2285.    .$  The first graphics demo, "Spiral Galaxy", displays simple pixel plotting.$
  2286.    2CR
  2287.    ."  We retain the standard eight colour screen for this demonstration."
  2288.    3CR
  2289.    ."  You can use the <M> key to repeatedly overplot the display area, creating"
  2290.    1CR
  2291.    ."  various semi-randomised effects."
  2292.    2CR
  2293.    ."  Try holding down the <M> key for some time, allowing various colour"
  2294.    1CR
  2295.    ."  effects to manifest."
  2296.    4CR
  2297.    ."  Use the colour control keys to get a feel for the effects of various"
  2298.    1CR
  2299.    ."  colour combinations."
  2300.    3CR
  2301.    ."  See how the numerical values of the red, green, and blue components"
  2302.    1CR
  2303.    ."  correlate with the colours and visual impressions produced."
  2304.  
  2305.    8 COLOURWAIT
  2306.  
  2307.    ' GALAXYDEMO CFA EXTERNAL !
  2308.  
  2309.    8 STREAM
  2310.  
  2311.    2 1 CURPUT  ." Let's try writing a few pixels."
  2312.  
  2313.    2 2 CURPUT  ." Press <M> to slowly define the spiral."
  2314.  
  2315.    2 3 CURPUT  ." Don't forget to play with the colours!"
  2316.  
  2317.    SHOWGALAXY
  2318.  
  2319.    ' NOOP CFA EXTERNAL !
  2320.  
  2321.    8 STREAM SCRCLR
  2322.  
  2323.    6 STREAM SCRCLR
  2324.    ;
  2325.  
  2326.  \ ---------------------------------------------------------------------------
  2327.  
  2328.   ( Introduce Fractals )
  2329.  
  2330.    : FRACTALINTRO    ( - - - )
  2331.  
  2332.    2 CANVAS 6 STREAM CURHM
  2333.  
  2334.    ."  Next we shall demonstrate simple line drawing by generating a series of"
  2335.    1CR
  2336.    ."  well known Fractal designs, again using the standard eight colour screen."
  2337.    2CR
  2338.    ."  Notice that ALL the graphics in this Demo are COMPUTED images as distinct"
  2339.    1CR
  2340.    ."  from predrawn pictures created in an art package and simply displayed."
  2341.    2CR
  2342.    ."  Considerable computing is required to generate even these simple images,"
  2343.    1CR
  2344.    ."  and they give a good indication of the speed and power of HeliOS."
  2345.    2CR
  2346.    ."  The Fractals you will see are all very well known examples, and you may"
  2347.    1CR
  2348.    ."  have access to other software which generates similar images.  If so you"
  2349.    1CR
  2350.    ."  you may like to compare the speed of HeliOS fractal generation with the"
  2351.    1CR
  2352.    ."  other software to get some idea of how just how fast HeliOS is."
  2353.    2CR
  2354.    ."  You may also be interested to know that computing these Fractal images"
  2355.    1CR
  2356.    ."  makes use of RECURSION, which is readily implemented in HeliOS."
  2357.    2CR
  2358.    ."  Remember that all the source code for this Demo is provided for you as a"
  2359.    1CR
  2360.    ."  simple tutorial exercise, so that by using and modifying the Demo code"
  2361.    1CR
  2362.    ."  you can soon be generating all manner of Fractal designs for yourself!"
  2363.  
  2364.    8 COLOURWAIT
  2365.    ;
  2366.  
  2367.  \ ---------------------------------------------------------------------------
  2368.  
  2369.   ( Introduce and show Landscape )
  2370.  
  2371.    : DOLANDSCAPE   ( - - - )
  2372.  
  2373.    2 CANVAS 6 STREAM CURHM
  2374.  
  2375.    ."  The second Fractal is another variant on the Koch design, this time"
  2376.    1CR
  2377.    ."  building on a horizontal line initial generator. It is known as the"
  2378.    1Cr
  2379.    .$  "Koch Landscape", for reasons only requiring a little imagination.$
  2380.    2CR
  2381.    ."  It is interesting that there is only a minor difference in the computing"
  2382.    1CR
  2383.    ."  procedure required to produce this and the previous design."
  2384.    2CR
  2385.    ."  Again you can use the <M> key to redraw the image, with each Landscape"
  2386.    1CR
  2387.    ."  constructed using slightly different random parameters."
  2388.    2CR
  2389.    ."  Notice again how the pattern is generated by imposing a similar"
  2390.    1CR
  2391.    ."  deformation upon each of the lines which make up the design."
  2392.    3CR
  2393.    ."  Again the colour control keys can be used to experiment with different"
  2394.    1CR
  2395.    ."  colour combinations."
  2396.    2CR
  2397.    ."  N.B."
  2398.    1CR
  2399.    ."  There are very many variations of these Fractal designs, so be sure"
  2400.    1CR
  2401.    ."  to press <M> plenty of times to view the possibilities."
  2402.  
  2403.    8 COLOURWAIT
  2404.  
  2405.    '  LANDSCAPEDEMO CFA  EXTERNAL !
  2406.  
  2407.    8 STREAM
  2408.  
  2409.    2 1 CURPUT  ." Try adjusting the colours."
  2410.  
  2411.    2 2 CURPUT  ." Press <M> to generate a new Landscape."
  2412.  
  2413.    2 3 CURPUT  ." Notice the simple repeated procedure."
  2414.  
  2415.    SHOWLANDSCAPE
  2416.  
  2417.    ' NOOP  CFA EXTERNAL !
  2418.  
  2419.    8 STREAM SCRCLR
  2420.  
  2421.    6 STREAM SCRCLR
  2422.    ;
  2423.  
  2424.  \ ---------------------------------------------------------------------------
  2425.  
  2426.   ( Introduce and show Dragon )
  2427.  
  2428.    : DODRAGON     ( - - - )
  2429.  
  2430.    2 CANVAS 6 STREAM CURHM
  2431.  
  2432.    ."  The next Fractal is yet another variant on the Koch curve, this time"
  2433.    1CR
  2434.    ."  building on a simple bent line initial generator. It is known as the"
  2435.    1CR
  2436.    .$  "Dragon Curve" because of its similarity to Chinese Dragon designs.$
  2437.    2CR
  2438.    ."  Once again the program to produce this Fractal is very similar to the"
  2439.    1CR
  2440.    ."  ones for the earlier designs."
  2441.    2CR
  2442.    ."  Again you can use the <M> key to redraw the image, with each Dragon"
  2443.    1CR
  2444.    ."  constructed using slightly different random parameters."
  2445.    2CR
  2446.    ."  These many different Fractals are produced by minor procedural changes,"
  2447.    1CR
  2448.    ."  and you will find many new interesting forms by experimenting with the"
  2449.    1CR
  2450.    ."  material provided in the Demo source code."
  2451.  
  2452.  
  2453.    8 COLOURWAIT
  2454.  
  2455.    ' DRAGONDEMO  CFA EXTERNAL !
  2456.  
  2457.    8 STREAM
  2458.  
  2459.    2 1 CURPUT  ." Try adjusting the colours."
  2460.  
  2461.    2 2 CURPUT  ." Press <M> to generate a new Dragon."
  2462.  
  2463.    2 3 CURPUT  ." Some are more Dragon-like than others. Why?"
  2464.  
  2465.    SHOWDRAGON
  2466.  
  2467.    ' NOOP    CFA EXTERNAL !
  2468.  
  2469.    8 STREAM SCRCLR
  2470.  
  2471.    6 STREAM SCRCLR
  2472.    ;
  2473.  
  2474.  \ ---------------------------------------------------------------------------
  2475.  
  2476.   ( Introduce and show C-Curve )
  2477.  
  2478.    : DOCCURVE     ( - - - )
  2479.  
  2480.    2 CANVAS 6 STREAM CURHM
  2481.  
  2482.    ."  The final Koch curve example is called the C-Curve, for the unimaginative"
  2483.    1CR
  2484.    .$  reason that it resembles a "C" turned on its side!$
  2485.    2CR
  2486.    ."  Once again the program to produce the C-Curve is nearly identical to the"
  2487.    1CR
  2488.    ."  ones for the earlier designs."
  2489.    2CR
  2490.    ."  Again you can use the <M> key to redraw the image, with each C-Curve"
  2491.    1CR
  2492.    ."  constructed using slightly different random parameters."
  2493.    2CR
  2494.    ."  Remember that there are a very large number of semi-random designs"
  2495.    1CR
  2496.    ."  possible, and you will often generate spectacularly fine pictures quite"
  2497.    1CR
  2498.    ."  suddenly within a long run of more mundane examples."
  2499.    2CR
  2500.    ."  KEEP trying!"
  2501.  
  2502.    8 COLOURWAIT
  2503.  
  2504.    ' CCURVEDEMO  CFA  EXTERNAL !
  2505.  
  2506.    8 STREAM
  2507.  
  2508.    2 1 CURPUT  ." Try adjusting the colours."
  2509.  
  2510.    2 2 CURPUT  ." Press <M> to generate a new C-Curve."
  2511.  
  2512.    2 3 CURPUT  ." This uses a slightly modified Dragon process."
  2513.  
  2514.    SHOWCCURVE
  2515.  
  2516.    ' NOOP   CFA EXTERNAL !
  2517.  
  2518.    8 STREAM SCRCLR
  2519.  
  2520.    6 STREAM SCRCLR
  2521.    ;
  2522.  
  2523.  \ ---------------------------------------------------------------------------
  2524.  
  2525.   ( Introduce and show Area Demos )
  2526.  
  2527.    :  DOAREADEMOS    ( - - - )
  2528.  
  2529.    2 CANVAS 6 STREAM CURHM
  2530.  
  2531.    ."  Of course the HeliOS system will also do area fill graphics, so let's go"
  2532.    1CR
  2533.    ."  round the Fractals once again, this time using filled coloured areas."
  2534.    1CR
  2535.    ."  You will notice that in many cases the speed of the plot, and also the"
  2536.    1CR
  2537.    ."  detail revealed, is not really affected by changing to filled graphics."
  2538.    2CR
  2539.    ."  In fact, only the less detailed displays really benefit from the filled"
  2540.    1CR
  2541.    ."  area approach, because with the more detailed designs the line plotting"
  2542.    1CR
  2543.    ."  effectively fills the display area with fine detail."
  2544.    2CR
  2545.    ."  One of the parameters randomly assigned for each Fractal generation is"
  2546.    1CR
  2547.    .$  "Depth of Recursion", which effectively determines the amount of detail$
  2548.    1CR
  2549.    ."  generated within the picture. The deeper the recursion, the slower the"
  2550.    1CR
  2551.    ."  overall drawing becomes, but within limits the detail becomes finer."
  2552.    2CR
  2553.    ."  After a certain point, the resolution of the display limits the detail"
  2554.    1CR
  2555.    ."  which further levels of recursion can reveal, but slowness of drawing can"
  2556.    1CR
  2557.    ."  also give greater colour variation from the semi-random colour routine."
  2558.    2CR
  2559.    ."  You can see from all this that creative graphic computing involves many"
  2560.    1CR
  2561.    ."  diverse and complex factors, and in fact becomes almost artistic."
  2562.  
  2563.    MAKEAREAPLOT
  2564.  
  2565.    8 COLOURWAIT
  2566.  
  2567.    8 STREAM
  2568.  
  2569.    2 1 CURPUT  ." Try adjusting the colours."
  2570.  
  2571.    2 2 CURPUT  ." Press <M> to generate a new picture."
  2572.  
  2573.    2 3 CURPUT  ." Experiment!"
  2574.  
  2575.    ' SNOWFLAKEDEMO   CFA EXTERNAL !
  2576.  
  2577.    SHOWSNOWFLAKE
  2578.  
  2579.    2 CANVAS2
  2580.  
  2581.    ' LANDSCAPEDEMO  CFA  EXTERNAL !
  2582.  
  2583.    SHOWLANDSCAPE
  2584.  
  2585.    2 CANVAS2
  2586.  
  2587.    ' DRAGONDEMO  CFA EXTERNAL !
  2588.  
  2589.    SHOWDRAGON
  2590.  
  2591.    2 CANVAS2
  2592.  
  2593.    ' CCURVEDEMO  CFA EXTERNAL !
  2594.  
  2595.    SHOWCCURVE
  2596.  
  2597.    2 CANVAS2
  2598.  
  2599.    ' NOOP CFA EXTERNAL !
  2600.  
  2601.    8 STREAM SCRCLR
  2602.  
  2603.    6 STREAM SCRCLR
  2604.    ;
  2605.  
  2606.  \ ---------------------------------------------------------------------------
  2607.  
  2608.    : DEMO      ( - - - )
  2609.  
  2610.    FSCREEN SCREENTOFRONT          \ Make sure HeliOS screen is at front
  2611.  
  2612.    FWINDOW MAKEGFXWINDOW          \ Make FWINDOW the current GFX window
  2613.  
  2614.    HELIOS                         \ Sun
  2615.  
  2616.    INTRO                          \ Introduction
  2617.  
  2618.    TEXTDEMO                       \ Text demo
  2619.  
  2620.    HELIOS                         \ Sun
  2621.  
  2622.    WINDOWSDEMO                    \ Windows demo
  2623.  
  2624.    HELIOS                         \ Sun
  2625.  
  2626.    MAKELINEPLOT                   \ Set up for line plotting
  2627.  
  2628.    GFXINTRO                       \ Introduce graphic demos
  2629.  
  2630.    DOGALAXY                       \ Spiral Galaxy
  2631.  
  2632.    FRACTALINTRO                   \ Introduce fractals
  2633.  
  2634.    DOSNOWFLAKE                    \ Snowflake fractal
  2635.  
  2636.    DOLANDSCAPE                    \ Landscape fractal
  2637.  
  2638.    DODRAGON                       \ Dragon fractal
  2639.  
  2640.    DOCCURVE                       \ C-Curve fractal
  2641.  
  2642.    DOAREADEMOS                    \ Area fractal demos
  2643.  
  2644.    HELIOS                         \ Sun
  2645.  
  2646.    DOMANDEL                       \ Mandelbrot demo
  2647.  
  2648.    HELIOS                         \ Sun
  2649.  
  2650.    DEMOQUIT                       \ Quit demo
  2651.    ;
  2652.  
  2653.  \ ----------------------------------------------------------------------------
  2654.  
  2655.   DEMO
  2656.  
  2657.  \ ----------------------------------------------------------------------------
  2658.